<template>
  <div id="app">
    <div class="content">
      <el-form ref="form" :model="form">
        <el-form-item>
          <el-input v-model="form.username" placeholder="学号"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.pwd" placeholder="身份证后6位"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.address" placeholder="所在地区"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.dm" placeholder="地区码"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.cj" placeholder="晨检温度"></el-input>
        </el-form-item>
        <el-form-item>
          <el-input v-model="form.wj" placeholder="午检温度"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="submit(form)">一键打卡！</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
/* eslint-disable */
import { RSA } from "../../assets/security.js";
export default {
  name: "",
  data() {
    return {
      form: {
        username: "1810609215",
        pwd: "200415",
        cj: "36.1",
        wj: "36.1",
        address: "重庆市北碚区",
        dm: "500109"
      },
      execution: "",
      modulus: "",
      exponent: "",
      apwd: "",
      pv: "",
      session: "",
      data: "",
    };
  },
  mounted() {
    this.getUrl(), this.getKey(), RSA(window);
  },
  methods: {
    getUrl() {
      this.axios
        .get(
          "/api/cas/login?service=http://xsc.cque.edu.cn:866/Mobile/login.aspx"
        )
        .then((res) => {
          // 转为jquery对象
          let htmlDom = $(res.data);
          let execution = htmlDom.find("input[name='execution']")[0].value;
          this.execution = execution;
        });
    },
    getKey() {
      this.axios.get("/local/getkey").then((res) => {
        let pv = res.data[0].cookie[1].slice(5, -28);
        let session = res.data[0].cookie[0].slice(11, -21);
        this.pv = pv;
        this.session = session
        this.modulus = res.data[0].modulus;
        this.exponent = res.data[0].exponent;
      });
    },
    submit(form) {
      let key = RSAUtils.getKeyPair(this.exponent, "", this.modulus);
      let resersepwd = form.pwd.split("").reverse().join("");
      let apwd = RSAUtils.encryptedString(key, resersepwd);
      this.apwd = apwd;

      this.axios.get('/local/login', {
        params: {
          username: form.username,
          password: apwd,
          cj: form.cj,
          wj: form.wj,
          address: form.address,
          dm: form.dm,
          execution: this.execution,
          pv: this.pv,
          session: this.session
        }
      }).then((res) => {
        console.log(res.data)
        // if(res.data) {
        //   this.axios.get('/local/login2', {
        //     params: {
        //       lo: res.data
        //     }
        //   }).then((res) => {
        //     console.log(res.data)
        //   })
        // }
      })

      // this.axios({
      //   url: '/api/cas/login?service=http://xsc.cque.edu.cn:866/Mobile/login.aspx',
      //   method: 'post',
      //   data: this.data,
      //   headers: {
      //     'Content-Type': 'application/x-www-form-urlencoded',
      //     'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9',

      //   }
      // })

      // var data = JSON.stringify({
      //   username: "1810609215",
      //   password:
      //     "70d778e6780b76238410e222eef9fdbcf824346fffbd33ccffeb5f9bf5308aacd6a254e0d4d2972172cdb05a8de6f40e7f796f05872eb7e77e202d6f4788145f",
      //   authcode: "",
      //   execution:
      //     "12227816-bc85-4e56-8d4f-01c9729396fe_ZXlKaGJHY2lPaUpJVXpVeE1pSjkuTkZOWGFIQkdVMGhrU1dsRU1XTXhUWGRvVFdwTmNuazJiVkp1TW1oQlFtdDBZa1V6Y0U0MmVIQnpha3ROUm5sS1VHZGpMek16VGprMlRYWmlXa3cyTUhFNWRtNUpOMmRCVTFaNlYzSk5aazFyUTFKb1pEVlVZbE5KYUZabWRISndkalpSUjJSR1VWbENjSGhyWnpWVGJtVnFNRWxXY1dKSmQyUTRSWEpMU1RKQlVVWXlOVlpYVGxwaVNuTTBRbXQwUXk5UU0wUTJVbWhCVDFnNFRHMU9NRzlCWkVkR2VuVjJkWGxwZEZwNU5EVnhjRTF2V1RVNGN6ZHRLMFI0ZW1zeGRuVlpja2hNTW1oT2IybGpkMU41TkVoSFoydFhVVTVPTmpCcFoxTkdTekZPTUZKaVVYRkthRVJUZGt4b1MyRm5SRmRJVTJzMWVFMXJlRFZ4VGxreGJFTmtOW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hMU4wU1VSVmQwdHljR1ZFU2tWNU0wOVBkelZrVTJSTmRteGpjMmRRWVdOT1NVRldTRzVwWW1NMVNscG1lbmxpU1hKWFIwbzFWMW9yYUdKU2FFMWFVbHB0YjBWdVp6RlJURWx4THpRdlVFUm5Xa3RtT0VWbFdVWnlPRzgxWW1zMFQwMDNUV1ZEYTJsSFUwVlVSWGxSZFZwR1RGSXZTbGhLUTNWalJrUlZNVkJyTnpCbVJsUjBNRmRSZFhCalMzTTRSRUZrYTI0NFIwZEVkRTVvVVZkSFUycFVNV1JHVFc5NFJVdDBTVE55UnpSUVdtcHRVRmcwTVRkTWVtdFhSWEptVkM5MGRYVklhR0ZUYzBWMVdFMHhVMWN5TkdWWFRWaFRaMmhpYUVSV1NHdG9UMDFPUmtWUUsxbGlkRlExUlM5bkt6WldSV0ZIVURneGJXMXVNR01yWVVsblVrVldhek51YUZFMlVtZDJObFUyVUU5R2RtdG1jVkpsTTNkamNrNXlORXBhWWtGdmJGcGtWM0J0V0ZNMFVFaFRNVTVtVEhRelMxbExObFo2UnpSSUswVXlOSGhyWlU5S1Iya3hhSElyU1hSNGFuUm9XRlU5LlozUXdFWGJ5ZTNVV2dkNTg5WVRjd0Y5dWtFd2ZrZ0tUSEVkQzFCQW5aUzZ4TTFrU01kSE9vQ3VYYTBjWnhNNE5hS2o0dUpyRU9LUWU3dFh2WldpTlBB",
      //   _eventId: "submit",
      // });
      // var config = {
      //   method: "post",
      //   url:
      //     "/api/cas/login?service=http://xsc.cque.edu.cn:866/Mobile/login.aspx",
      //   headers: {
      //     "Content-Type": "application/x-www-form-urlencoded",
      //     Cookie:
      //       "_pv0=ReQUUK6LInNdHAKB0hI69mO%2B799FaFe%2Bon7jOfETXtY1EavUg%2FDEA3wtHW8jbSwHEtpNZabgZF5bDLHk8EKAXZ6KWcwOSol78AAEcGJDpl70ZxZ4V4zlMqA9E4CBa9TgeMJqBuuSrQvRXrCw9%2Fw1Cx9OqJYeL6JmsUrfpqJUojHzaNXuDwUv0Md%2FC4lvJWuk8IROUMUUWjte8GdTeVstqnLbnuXNLM%2FJAz%2BADmBVjnOmPIJvtPWtzyrSuMZA1D6SF1iQTds6PZJWRMvfHs90ORHSS%2B7FEIerQgPzN7fhDhPtTj8fAnfhjyc6c%2BFugMFwidIYrlltySGDkhtLR6HOtWyz0L%2BRAdtm36a4hsBioQxxrO2LPqKiAWIYo0nlAbl6ZlLGN4N1h%2Bu7XJBHBgrb8lfSqEgQUFuRj0W5bOvqR6E%3D",
      //   },
      //   data: data,
      // };

      // this.axios(config)
      //   .then(function (response) {
      //     console.log(JSON.stringify(response.data));
      //   })
      //   .catch(function (error) {
      //     console.log(error);
      //   });
    },
  },
};
</script>

<style scoped>
#app {
  width: 100%;
  height: 100vh;
  background-image: url("../../assets/bg.jpg");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  display: flex;
  flex-direction: column;
}

.content {
  width: 80%;
  margin: 150px auto 0px auto;
}
</style>
